package com.bjesc_b2c.app.appraiset.mvp.model.impl;

import android.content.Context;

import com.bjesc_b2c.app.appraiset.http.IApiActivityRequest;
import com.bjesc_b2c.app.appraiset.mvp.model.CarBrandModel;
import com.rxretrofit_build.util.MapUtil;

import java.util.List;

import master_bean.SelectCarBrandBean;
import rxretrofit_base.model.ShowType;
import rxretrofit_base.model.TokenBean;
import rxretrofit_base.net.BaseSubscriber;
import rxretrofit_base.net.RxRequest;

/**
 * Created by lenovo on 2017/3/1.
 */

public class CarBrandModelImpl implements CarBrandModel {
    private CallBack callBack;

    public CarBrandModelImpl(CallBack callBack) {
        this.callBack = callBack;
    }

    @Override
    public void reuestCarBrand(Context context) {
        RxRequest.request(ShowType.SHOW, RxRequest.getClient(context, new MapUtil().build()).create(IApiActivityRequest.class).getCarBrand(),
                new BaseSubscriber<TokenBean<List<SelectCarBrandBean>>>(context) {
                    @Override
                    public void onSuccess(TokenBean<List<SelectCarBrandBean>> o) {
                        if(callBack!= null){
                            callBack.callBack(o.getData());
                        }
                    }

                    @Override
                    public void onFailure(Throwable e) {

                    }
                });
    }

    public  interface CallBack{
        void callBack(List<SelectCarBrandBean> brandList);
    }
}
